layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,$ = layui.$;
  
  //日期
  laydate.render({
    elem: '#date'
  });
  laydate.render({
    elem: '#date1'
  });
  
  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');
 
  //自定义验证规则
  form.verify({
    title: function(value){
      if(value.length < 5){
        return '标题至少得5个字符啊';
      }
    }
    ,pass: [/(.+){6,12}$/, '密码必须6到12位']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });
  
  //监听指定开关
  form.on('switch(switchTest)', function(data){
    layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
      offset: '6px'
    });
    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    // layer.alert(JSON.stringify(data.field), {
    //   title: '最终的提交信息'
    // });
    // return false;
  });

  //点击预约弹窗测试
$('.bb').on('click',function(){
  	layer.open({
		type:1,
		title:'',
		closeBtn:0,
		shadeClose:true,
		area:['4.8rem','auto'],
		content:$('#yySuccess'),
		isOutAnim:true,
	})
  })
//取消预约
$('.qxx').on('click',function(){
	$('.layui-layer-shade').trigger('click');
})
$('')
  //预约成功弹窗测试
$('.cc').on('click',function(){
  	layer.open({
		type:1,
		title:'',
		shadeClose:true,
		area:['4.8rem','auto'],
		content:$('#yuyueSucess'),
		isOutAnim:true,
	})
  })
	//查看课程
	$('.lii .h3').on('click',function(){
			$(this).siblings('.ull').slideToggle();
	})
});

//地区选择
var area2 = new LArea();
    area2.init({
        'trigger': '#selectCity',
        'valueTo': '#value2',
        'keys': {
            id: 'value',
            name: 'text'
        },
        'type': 2,
        'data': [provs_data, citys_data, dists_data]
    });
